﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.OData;
using System.Web.Http.OData.Query;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_DataLayer;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_DomainLayer;


///http://marknic.net/2013/03/02/add-an-odata-feed-to-your-app-using-web-api/

namespace MPC_PI_ContactManager.Controllers.ODataControllers
{
    public class ContactsController : ODataController //EntitySetController<v_Contact,int>
    {
        [Queryable]
        public IQueryable<v_Contact> Get()
        {
            IQueryable<v_Contact> toReturn;
            DataRepositories _dataContext = new DataRepositories();
                toReturn = _dataContext.v_Contact_Rep.GetAll().AsQueryable();
            return toReturn;
        }

        public v_Contact GetByKey([FromODataUri] int key) {
            v_Contact toReturn;
            DataRepositories _dataContext = new DataRepositories();
            toReturn = _dataContext.v_Contact_Rep.GetById(key);
            return toReturn;
        }
        /// <summary>
        /// http://stephenwalther.com/archive/2010/03/30/using-jquery-and-odata-to-insert-a-database-record.aspx
        /// </summary>
        public void Post() { 
            
        }
    }
}